package com.evamay.kotlindemo.ui.viewpager

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.evamay.kotlindemo.R
import com.evamay.kotlindemo.entity.TypeInfo
import com.evamay.kotlindemo.ui.main.MainAdapter
import kotlinx.android.synthetic.main.activity_view_pager_menu.*

class ViewPagerMenuActivity :Activity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_view_pager_menu)
        initData()

    }

    private fun initData() {
        var list=ArrayList<TypeInfo>()
        list.add(TypeInfo(1,"ViewPager2横向滑动"))
        list.add(TypeInfo(2,"ViewPager2纵向滑动"))
        list.add(TypeInfo(3,"ViewPager2禁用滑动"))
        list.add(TypeInfo(4,"ViewPager2设置间距"))
        list.add(TypeInfo(5,"ViewPager2设置组合动画"))
        list.add(TypeInfo(6,"ViewPager2设置一平多页"))
        list.add(TypeInfo(7,"ViewPager2嵌套Fragment"))
        rv_view_pager_main.layoutManager=LinearLayoutManager(this)
        var mAdapter=MainAdapter(this,list)
        rv_view_pager_main.adapter=mAdapter
        mAdapter.setClickListener(object :MainAdapter.OnItemClickListener{
            override fun onItemClick(position: Int) {
                var intent=Intent(baseContext,ViewPagerActivity::class.java)
                intent.putExtra("type",list[position].type)
                startActivity(intent)
            }

        })
    }

}